package org.dulong.interceptor;

import org.dulong.service.impl.IAopServiceImpl;
import org.springframework.aop.MethodBeforeAdvice;

import java.lang.reflect.Method;

/**
 * Created with IntelliJ IDEA.
 * User: Administrator
 * Date: 13-9-23
 * Time: 下午1:21
 * To change this template use File | Settings | File Templates.
 */
public class MethodBeforeInterceptor implements MethodBeforeAdvice {
    @Override
    public void before(Method method, Object[] objects, Object o) throws Throwable {
        System.out.println("即将要执行方法：" + method.getName());
        if (o instanceof IAopServiceImpl) {
            String name = ((IAopServiceImpl) o).getName();
            if(name == null){
                throw new NullPointerException("name属性不能为空");
            }
        }

    }
}
